#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int x[100010],y[100010],t[100010],f[100010];
int main(){
    int n,m;
    cin>>n>>m;
    int ans=0;
    for(int i=1;i<=m;i++){
        cin>>t[i]>>x[i]>>y[i];
        f[i]=1;
        for(int j=1;j<i;j++)
        {
            if(f[i]<f[j]+1&&(abs(x[i]-x[j])+abs(y[i]-y[j]))<=(t[i]-t[j])){
                f[i]=f[j]+1;
            }
            
        }
        ans=max(ans,f[i]);
    }
    cout<<ans;
    return 0;
}